<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: client_view.php 62 2007-09-10 06:40:30Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(dirname(__FILE__) . '/_meta_client.php');
echo $this->render('header.php');
$client = $this->client;
?>
<div id="Content">
  <div class="Tips">在进行任何删除，修改操作的时候，务必小心确认！</div>
  <h2>客户 <a href="<?php echo $client['website']; ?>"><?php echo $client['company']; ?></a><span><a href="<?php echo $this->base_url; ?>/edit/id/<?php echo $client['id']; ?>">编辑</a>
    <?php
if($client['deleted_at']):
?>
    <a href="<?php echo $this->base_url; ?>/restore/id/<?php echo $client['id']; ?>">恢复删除</a>
    <?php
else:
?>
    <a href="<?php echo $this->base_url; ?>/trash/id/<?php echo $client['id']; ?>">标记删除</a>
    <?php
endif;
?>
    <a href="<?php echo $this->base_url; ?>/delete/id/<?php echo $client['id']; ?>" onclick="return confirm('确认删除客户“<?php echo $client['company']; ?>”及其相应联系人？')">删除</a> </span> </h2>
  <style type="text/css">
.CurInfo h2.Title {
display:none;
}
</style>
  <div id="InfoSelectorTarget"></div>
  <div id="ClientInfo">
    <table>
      <tr>
        <td><?php echo $meta['client']['fields']['id'];?></td>
        <td><?php echo $client['id'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['client_type_code'];?></td>
        <td><?php echo $this->client_types[$client['client_type_code']];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['trade_type_id'];?></td>
        <td><?php echo $this->trade_types[$client['trade_type_id']];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['company'];?></td>
        <td><?php echo $client['company'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['website'];?></td>
        <td><?php echo $client['website'];?></td>
      </tr>      <tr>
        <td><?php echo $meta['client']['fields']['alexa'];?></td>
        <td><?php echo $client['alexa'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['phone'];?></td>
        <td><?php echo $client['phone'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['fax'];?></td>
        <td><?php echo $client['fax'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['email'];?></td>
        <td><?php echo $client['email'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['address'];?></td>
        <td><?php echo $client['address'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['postcode'];?></td>
        <td><?php echo $client['postcode'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['stage'];?></td>
        <td><?php echo $client['stage'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['contact_name'];?></td>
        <td><?php echo $client['contact_name'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['contact_email'];?></td>
        <td><?php echo $client['contact_email'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['contact_msn'];?></td>
        <td><?php echo $client['contact_msn'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['contact_qq'];?></td>
        <td><?php echo $client['contact_qq'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['contact_cellphone'];?></td>
        <td><?php echo $client['contact_cellphone'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['last_contact_at'];?></td>
        <td><?php echo $this->dateFormat($client['last_contact_at']);?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['last_contact_by'];?></td>
        <td><?php echo $client['last_contact_by'];?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['created_at'];?></td>
        <td><?php echo  $this->dateFormat($client['created_at']);?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['updated_at'];?></td>
        <td><?php echo  $this->dateFormat($client['updated_at']);?></td>
      </tr>
      <tr>
        <td><?php echo $meta['client']['fields']['deleted_at'];?></td>
        <td><?php echo $this->dateFormat($client['deleted_at']);?></td>
      </tr>
    </table>
  </div>
  <div id="ClientContactHistory">
    <?php
require_once(dirname(__FILE__) . '/_meta_contacthistory.php');
?>
    <h2 class="Title">联系历史<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
    <?php
        if(!$this->contact_histories):
	?>
    <div class="Tips"> 此客户暂时没有联系记录，请赶快联系客户并 <a href=" <?php echo $this->module_url;?>/contactHistory/add/client/<?php echo $this->client['id'] ?>">添加第一条联系记录</a> </div>
    <?php
        else:
	?>
    <a href=" <?php echo $this->module_url;?>/contactHistory/add/client/<?php echo $client['id'] ?>">新增</a> <a href=" <?php echo $this->module_url;?>/contactHistory/list/client/<?php echo $client['id'] ?>">全部</a>
    <table cellspacing="0" cellpadding="0" id="client_contact_history_list" class="tblborder">
      <tr class="tblhead">
        <td><?php echo $meta['contact_history']['fields']['id'];?> </td>
        <td><?php echo $meta['contact_history']['fields']['contact_at'];?> </td>
        <td><?php echo $meta['contact_history']['fields']['contact_by'];?> </td>
        <td><?php echo $meta['contact_history']['fields']['conclusion'];?> </td>
        <td><?php echo $meta['contact_history']['fields']['report_at'];?> </td>
        <td> 操作 </td>
      </tr>
      <?php
        foreach ($this->contact_histories as $contact_history):
	?>
      <tr class="tblbody">
        <td><?php echo $contact_history['id']; ?></td>
        <td><?php echo $this->dateFormat($contact_history['contact_at']); ?></td>
        <td><?php echo $LANG['CONTACT_BY'][$contact_history['contact_by']]; ?></td>
        <td><?php echo $contact_history['conclusion']; ?></td>
        <td><?php echo $this->dateFormat($contact_history['report_at']); ?></td>
        <td><a href="<?php echo $this->module_url;?>/contactHistory/view/id/<?php echo $contact_history['id'] ?>">查看</a> </td>
      </tr>
      <?php
        endforeach;
	?>
    </table>
 <?php
  endif;
	?>
  </div>
  <div id="ClientContacts">
    <?php
require_once(dirname(__FILE__) . '/_meta_contact.php');
?>
    <h2 class="Title">联系人<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
      <?php
        if(!$this->contacts):
	?>
    <div class="Tips"> 此客户暂时没有联系人，请添加主要联系人 <a href=" <?php echo $this->module_url;?>/contact/add/primary/1/client/<?php echo $this->client['id'] ?>">新增联系人</a> </div>
    <?php
        else:
	?>
    <a href=" <?php echo $this->module_url;?>/contact/add/client/<?php echo $client['id'] ?>">新增</a> <a href=" <?php echo $this->module_url;?>/contact/list/client/<?php echo $client['id'] ?>">全部</a>
    <table cellspacing="0" cellpadding="0" id="client_contact_list" class="tblborder">
      <tr class="tblhead">
        <td><?php echo $meta['contact']['fields']['name'];?></td>
        <td><?php echo $meta['contact']['fields']['email'];?></td>
        <td><?php echo $meta['contact']['fields']['qq'];?></td>
        <td><?php echo $meta['contact']['fields']['phone'];?></td>
        <td><?php echo $meta['contact']['fields']['cellphone'];?></td>
        <td><?php echo $meta['contact']['fields']['is_primary'];?></td>
        <td><?php echo $meta['contact']['fields']['created_at'];?></td>
        <td><?php echo $meta['contact']['fields']['updated_at'];?></td>
        <td> 操作 </td>
      </tr>
      <?php
        foreach ($this->contacts as $contact):
	?>
      <tr class="tblbody">
        <td><?php echo $contact['name'];?></td>
        <td><a href="mailto:"><?php echo $contact['email'];?></a> </td>
        <td><?php echo $contact['qq'];?></td>
        <td><?php echo $contact['phone'];?></td>
        <td><?php echo $contact['cellphone'];?></td>
        <td><?php echo $contact['is_primary'];?></td>
        <td><?php echo date('Y-m-d', $contact['created_at']);?></td>
        <td><?php echo date('Y-m-d', $contact['updated_at']);?></td>
        <td><a href="<?php echo $this->module_url;?>/contact/view/id/<?php echo $contact['id'] ?>">查看</a>
        <?php
            if($contact['is_primary']=='N'):
            ?>
            <a href="<?php echo $this->module_url;?>/contact/primary/client/<?php echo $contact['client_id'];?>/id/<?php echo $contact['id'] ?>">设为主要</a>
            <?php
            endif;
            ?>
        <a href="<?php echo $this->module_url;?>/contact/edit/id/<?php echo $contact['id'] ?>">编辑</a> <a href="<?php echo $this->module_url;?>/contact/trash/id/<?php echo $contact['id'] ?>">删除</a> </td>
      </tr>
      <?php
        endforeach;
        endif;
	?>
    </table>
  </div>
  <div id="ClientMemo">
    <h2 class="Title" >备注<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
    <p> <?php echo $client['memo'];?></p>
  </div>
  <script language="JavaScript" type="text/javascript" src="<?php echo $this->wwwroot;?>/js/taobao_tabs.js"></script>
  <script language="JavaScript" type="text/javascript">
	var TabNames = [];
	var TabIds =[];
	convertTabMap({
		'ClientInfo':'客户信息',
		'ClientContactHistory':'联系历史',
		'ClientContacts':'联系人',
		'ClientMemo':'备注'
	});
	initInfoSelector();
</script>
</div>
<?php
echo $this->render('footer.php');
?>